package com.qf.ssm.provider;


import com.alibaba.druid.util.StringUtils;
import com.qf.ssm.pojo.User;

public class UserSqlProvider {

    public String getUpdateSql(User userDto) {
        StringBuffer stringBuffer = new StringBuffer("UPDATE users SET");
        if (!StringUtils.isEmpty(userDto.getPassword())) {
            stringBuffer.append(" password = #{password},");
        }
        if (!StringUtils.isEmpty(userDto.getType())) {
            stringBuffer.append(" type = #{type},");
        }
        if (!StringUtils.isEmpty(userDto.getStatus())&&!userDto.getStatus().equalsIgnoreCase("-100")) {
            stringBuffer.append(" status = #{status},");
        }
        stringBuffer.deleteCharAt(stringBuffer.lastIndexOf(","));
        stringBuffer.append(" WHERE id = #{id}");
        return stringBuffer.toString();
    }

}
